<html>

<head>
    <meta charset="utf-8" />
    <link href="css/github-markdown.css" type="text/css" rel="stylesheet"></link>
    <script src="js/jquery-3.2.1.min.js"></script>
    <script>
        $(function () {
            document.designMode = "on";
            document.contentEditable = true;
            window.parent.editorFrame = document;
            document.changeLink = function (url) {
                $('a[href="LINK_TEMP"').attr('target', '_blank');
                $('a[href="LINK_TEMP"').attr('href', url);
            }
            // document.onkeydown = function (e) {
            //     //console.log(e);
            //     if (e.key == "Enter") {
            //         e.preventDefault();
            //         document.execCommand("insertHTML", "false", "<br/> &nbsp;");
            //     }
            // }
            document.body.onpaste = function (e) {
                var items = event.clipboardData.items;
                if(items[0].type == "text/plain"){
                    items[0].getAsString(function(str){
                        var temp = window.parent.htmlEncode(str);
                        document.execCommand("insertHTML","false",temp);
                    })
                    e.preventDefault();
                    return;
                }
                if (items[0].type.indexOf("image") < 0) {
                    return;
                }
                e.preventDefault();
                var file = items[0].getAsFile();
                window.parent.bky.uploadImg(file, function (url) {
                    var str = '<img src="' + url + '" /><div>&nbsp</div>';
                    document.execCommand("insertHTML", "false", str);
                    document.imgReady();
                })
            }
            function zoomImg() {
                    var w = $(this).width();
                    var h = $(this).height();
                    if(event.wheelDelta<0){
                        w -= w/60;
                        h -= h/60;
                    }else{
                        w += w/60;
                        h += h/60;
                    }
                    $(this).css({"height":h+"px","width":w+"px"});
                    return false;  
            }
            document.imgReady = function(){
                $("img").off();
                $("img").on("mousewheel", zoomImg);
            }
             
            // document.execCommand("insertBrOnReturn","false","true");
            // document.execCommand("enableInlineTableEditing","false","true");
            // document.execCommand("enableObjectResizing","false","true");
        })
    </script>
</head>

<body class="markdown-body" style="padding: 12px;"></body>

</html>